package com.foldingleaf.web.controller.record;

import com.foldingleaf.common.annotation.Log;
import com.foldingleaf.common.core.controller.BaseController;
import com.foldingleaf.common.core.domain.Result;
import com.foldingleaf.common.core.page.TableDataInfo;
import com.foldingleaf.common.enums.BusinessType;
import com.foldingleaf.common.utils.poi.ExcelUtil;
import com.foldingleaf.record.domain.SysCollectionOrderRecord;
import com.foldingleaf.record.service.ISysCollectionOrderRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 藏品订单记录Controller
 * 
 * @author ajian
 * @date 2022-06-04
 */
@Api(value = "/record/record", tags = {"藏品订单记录Controller"})
@RestController
@RequestMapping("/record/record")
public class SysCollectionOrderRecordController extends BaseController
{
    @Autowired
    private ISysCollectionOrderRecordService sysCollectionOrderRecordService;

    /**
     * 查询藏品订单记录列表
     */

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "SysCollectionOrderRecord", name = "sysCollectionOrderRecord", value = "")
    })
    @ApiOperation(value = "查询藏品订单记录列表", notes = "查询藏品订单记录列表", httpMethod = "GET")
    @GetMapping("/list")
    public TableDataInfo list(SysCollectionOrderRecord sysCollectionOrderRecord)
    {
        startPage();
        List<SysCollectionOrderRecord> list = sysCollectionOrderRecordService.selectSysCollectionOrderRecordList(sysCollectionOrderRecord);
        return getDataTable(list);
    }

    /**
     * 导出藏品订单记录列表
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "HttpServletResponse", name = "response", value = ""),
            @ApiImplicitParam(paramType = "query", dataType = "SysCollectionOrderRecord", name = "sysCollectionOrderRecord", value = "")
    })
    @ApiOperation(value = "导出藏品订单记录列表", notes = "导出藏品订单记录列表", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('record:record:export')")
    @Log(title = "藏品订单记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCollectionOrderRecord sysCollectionOrderRecord)
    {
        List<SysCollectionOrderRecord> list = sysCollectionOrderRecordService.selectSysCollectionOrderRecordList(sysCollectionOrderRecord);
        ExcelUtil<SysCollectionOrderRecord> util = new ExcelUtil<SysCollectionOrderRecord>(SysCollectionOrderRecord.class);
        util.exportExcel(response, list, "藏品订单记录数据");
    }

    /**
     * 获取藏品订单记录详细信息
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "collectionOrderRecordId", value = "")
    })
    @ApiOperation(value = "获取藏品订单记录详细信息", notes = "获取藏品订单记录详细信息", httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('record:record:query')")
    @GetMapping(value = "/{collectionOrderRecordId}")
    public Result getInfo(@PathVariable("collectionOrderRecordId") Long collectionOrderRecordId)
    {
        return Result.success(sysCollectionOrderRecordService.selectSysCollectionOrderRecordByCollectionOrderRecordId(collectionOrderRecordId));
    }

    /**
     * 新增藏品订单记录
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "SysCollectionOrderRecord", name = "sysCollectionOrderRecord", value = "")
    })
    @ApiOperation(value = "新增藏品订单记录", notes = "新增藏品订单记录", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('record:record:add')")
    @Log(title = "藏品订单记录", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody SysCollectionOrderRecord sysCollectionOrderRecord)
    {
        return toAjax(sysCollectionOrderRecordService.insertSysCollectionOrderRecord(sysCollectionOrderRecord));
    }

    /**
     * 修改藏品订单记录
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "SysCollectionOrderRecord", name = "sysCollectionOrderRecord", value = "")
    })
    @ApiOperation(value = "修改藏品订单记录", notes = "修改藏品订单记录", httpMethod = "PUT")
    @PreAuthorize("@ss.hasPermi('record:record:edit')")
    @Log(title = "藏品订单记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody SysCollectionOrderRecord sysCollectionOrderRecord)
    {
        return toAjax(sysCollectionOrderRecordService.updateSysCollectionOrderRecord(sysCollectionOrderRecord));
    }

    /**
     * 删除藏品订单记录
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "Long[]", name = "collectionOrderRecordIds", value = "")
    })
    @ApiOperation(value = "删除藏品订单记录", notes = "删除藏品订单记录", httpMethod = "DELETE")
    @PreAuthorize("@ss.hasPermi('record:record:remove')")
    @Log(title = "藏品订单记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{collectionOrderRecordIds}")
    public Result remove(@PathVariable Long[] collectionOrderRecordIds)
    {
        return toAjax(sysCollectionOrderRecordService.deleteSysCollectionOrderRecordByCollectionOrderRecordIds(collectionOrderRecordIds));
    }
}
